import { http1 } from '@/utils/http'
import type { mylogin } from '@/types/my'
export const loginAPIhou = (user) => {
  console.log('node后端接口接收')
  console.log('登录接口对接')

  // 登录请求
  return http1<any>({
    method: 'POST',
    url: `/api/login?username=${user.username}&password=${user.password}`,
  })
}
// token请求
export const tokenAPI = () => {
  console.log('token对接')

  return http1<any>({
    method: 'GET',
    url: '/user/profile',
  })
}
// 注册请求
export const registerAPIhou = (information) => {
  console.log('注册接口对接node')

  return http1<any>({
    method: 'POST',
    url: '/api/register',
    data: {
      ...information,
    },
  })
}
// 修改个人数据的请求
export const editMyDataAPI = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/editMyDataAPI',
    data: { obj },
  })
}
export const loginAPI1 = (user) => {
  console.log('微信接口对接')

  console.log(user, '微信user是')
  // 登录请求
  return http1<any>({
    method: 'GET',
    url: `/wx/user/login?appid=${user.appid}&appSecret=${user.appSecret}&code=${user.code}`,
  })
}
//开通会员
export const openVIP = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/openVIP',
    data: obj,
  })
}
//查询会员
export const getVIP = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/getVIP',
    data: obj,
  })
}
// 实现在线试卷查询
export const getsjuan = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/getsjuan',
    data: obj,
  })
}
// 预览
export const preview = () => {
  return http1<any>({
    method: 'GET',
    url: '/api/getDoc',
    responseType: 'blob', // 因为是流文件，所以要指定blob类型
  })
}
// 插入的试卷
export const insert = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/insert',
    data: obj,
  })
}
// 查询下载的试卷
export const getDoc22 = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/getDoc22',
    data: obj,
  })
}
//删除文件

export const deleteFile = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/deleteFile',
    data: obj,
  })
}
// 获取视频的列表
export const getVideoList = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/getVideoList',
    data: obj,
  })
}
// 获取视频单个数据
export const getVideo = (obj) => {
  return http1<any>({
    method: 'POST',
    url: '/api/getVideo',
    data: obj,
  })
}
// // 获取视频
export const getVideoAPI = (filename) => {
  return http1<any>({
    method: 'GET',
    url: `/api/getVideoAPI/${filename}`,
  })
}
